/**
 * 
 */
package com.wskj.library.service.impl;

import java.util.Date;
import java.util.List;

import com.wskj.library.dao.BookCategoryDao;
import com.wskj.library.dao.BookInfoDao;
import com.wskj.library.dao.BorrowInfoDao;
import com.wskj.library.dao.impl.BookCategoryDaoImpl;
import com.wskj.library.dao.impl.BookInfoDaoImpl;
import com.wskj.library.dao.impl.BorrowInfoDaoImpl;
import com.wskj.library.pojo.BookCategory;
import com.wskj.library.pojo.BookInfo;
import com.wskj.library.pojo.BorrowInfo;
import com.wskj.library.service.BookService;

/**
 * @author 胡洋
 * @describe  管理图书的服务层
 * @Date 2018年3月22日下午5:52:10
 * @version 1.0
 */
public class BookServiceImpl implements BookService {
    //图书分类信息处理 
	private BookCategoryDao cDao=new BookCategoryDaoImpl();
	//处理图书信息的dao
    private 	BookInfoDao  bookDao=new BookInfoDaoImpl();
	//处理借阅信息的dao
    private BorrowInfoDao borrowDao=new BorrowInfoDaoImpl();
	
    @Override
	public List<BookCategory> queryAllCategory() {	
		
		return cDao.getAllBookCategorys();
	}

	
	@Override
	public boolean saveBookInfo(BookInfo bookInfo) {
		int count = bookDao.addBookInfo(bookInfo);		
		return count>0?true:false;
	}


	@Override
	public BookInfo getBookById(int id) {
		
		return bookDao.getBookInfoById(id);
	}


	@Override
	public boolean updateBookInfo(BookInfo bookInfo) {
		int count = bookDao.updateBookInfo(bookInfo);
		return count>0?true:false;
	}


	@Override
	public boolean deleteBookById(int id) {
		int count = bookDao.deleteById(id);
		return count>0?true:false;
	}


	@Override
	public long getCountsByBname(String bname, String author, int cid, int status) {
		
		return bookDao.getCoutsByBname(bname,author,cid,status);
	}


	@Override
	public List<BookInfo> getBooksWithPage(String bname, String author, int cid, int status, int index, int pageSize) {
		
		return bookDao.getBookWithPage(bname,author,cid,status,index,pageSize);
	}


	
	@Override
	public boolean deleteBookById(String[] id) {
	 int count=bookDao.deleteAllBooks(id);
		return  count>0?true:false;
	}


	
	@Override
	public List<BookInfo> queryAllBooks() {		
		return bookDao.getAllBookInfos();
	}


	
	@Override
	public boolean saveBooks(List<BookInfo> books) {
		
		int count=bookDao.saveBooks(books);
		return count>0?true:false;
	}


	
	@Override
	public long getBorrowsCounts(String bname, String rname, Date borrowTime) {
		
		return borrowDao.getCounts(bname,rname,borrowTime);
	}


	
	@Override
	public List<BorrowInfo> getBorrowsWithPage(String bname, String rname, Date borrowTime, int index, int pageSize) {
		
		return borrowDao.getBorrowsWithPage(bname,rname,borrowTime,index,pageSize);
	}
  
	
	
}
